package com.ziyun.erp.modules.store.storeGoodsCategory.service.impl;

import com.utility.New;
import com.utility.StringUtils;
import com.ziyun.erp.modules.store.storeGoodsCategory.dao.StoreGoodsCategoryDao;
import com.ziyun.erp.modules.store.storeGoodsCategory.entity.StoreGoodsCategoryEntity;
import com.ziyun.erp.modules.store.storeGoodsCategory.service.StoreGoodsCategoryService;
import io.renren.common.utils.StringUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;



@Service("storeGoodsCategoryService")
public class StoreGoodsCategoryServiceImpl extends ServiceImpl<StoreGoodsCategoryDao, StoreGoodsCategoryEntity> implements StoreGoodsCategoryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<StoreGoodsCategoryEntity> page = this.selectPage(
                new Query<StoreGoodsCategoryEntity>(params).getPage(),
                new EntityWrapper<StoreGoodsCategoryEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<StoreGoodsCategoryEntity> select() {
        Map<String, Object> map = New.hashMap();
        map.put("del",0);
//        List<StoreGoodsCategoryEntity> storeGoodsCategoryList = this.baseMapper.selectByMap(map);
        List<StoreGoodsCategoryEntity> storeGoodsCategoryList = this.baseMapper.selectAllCategory();
        //添加顶级菜单
        StoreGoodsCategoryEntity storeGoodsCategoryEntity = new StoreGoodsCategoryEntity();
        storeGoodsCategoryEntity.setCategoryId(0);
        storeGoodsCategoryEntity.setCategoryName("顶级分类");
        storeGoodsCategoryEntity.setParentCategoryId(-1);
        storeGoodsCategoryList.add(storeGoodsCategoryEntity);
        return storeGoodsCategoryList;
    }

    @Override
    /**
     * 标记删除分类
     */
    public void flagDeleteGoodsCategory(Integer categoryIds) {
        this.baseMapper.flagDeleteGoodsCategory(categoryIds);
    }

//    @Override
//    public List<StoreGoodsCategoryEntity> selectAllList() {
//        return this.baseMapper.selectAllList();
//    }
}
